import 'dart:async';

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:wuxu_flutter_lianxi/app.dart';
import 'package:wuxu_flutter_lianxi/dao/UserDao.dart';
import 'package:wuxu_flutter_lianxi/env/config_wrapper_widget.dart';
import 'package:wuxu_flutter_lianxi/env/env_config.dart';
import 'package:wuxu_flutter_lianxi/page/error_page.dart';

import 'env/dev.dart';

void main() {
  //dart 提供的捕获内部崩溃的api,这里使用可以避免flutter页面出现错误提示
  runZonedGuarded(() {
    //设置全局ErrorWidget，当出现问题时展示
    ErrorWidget.builder = (FlutterErrorDetails details){
      //使用Zone控制异常的流程
      Zone.current.handleUncaughtError(details.exception, details.stack!);

      return ErrorPage();
    };

    //实现
    runApp(ConfigWrapperWidget(
        config: EnvConfig.fromJson(config), child: WXApp()));

    GestureBinding.instance.resamplingEnabled = true; //控制手势重采样，提高精度，但会损耗性能
  }, (Object error, StackTrace stack) {
    print(error);
    print(stack);
  });
}
